package com.ts.code.creator.express;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class ExpressContext {

    private Map<String, Object> map = new HashMap<>();

    private StringBuilder sb = new StringBuilder();

    public Object getObject(String name) {
        return map.get(name);
    }

    public void put(String key, Object obj) {
        map.put(key, obj);
    }

    public void put(Object obj) {
        Field[] fields = obj.getClass().getDeclaredFields();
        for (Field field : fields) {
            try {
                field.setAccessible(true);
                Object val = field.get(obj);
                map.put(field.getName(), val);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }

}
